package com.example.test;

import com.example.config.MySpringConfig;
import com.example.entity.UserEntity;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @Description:加载注解配置@Configuration spring 容器中对象默认是单例的
 * @Author: mingtian
 * @CreateDate: 2019/12/6 10:49
 * @Version: 1.0
 */
public class BeanTest02 {

    /**
     * 加载配置类
     */
    private static AnnotationConfigApplicationContext applicationContext;

    public static void main(String[] args) {

        applicationContext = new AnnotationConfigApplicationContext(MySpringConfig.class);
        applicationContext.getBean("");
        UserEntity userEntity = applicationContext.getBean("userEntity", UserEntity.class);
        System.out.println("userId:" + userEntity.getUserId() + ",userName:" + userEntity.getUserName());
    }
}